Fix Android issue with isUserInteraction always returning true when location puck is pulsing - #4222
Conversation
|
@KijongHan thanks much for the PR. I'd rather add onRegionIsChanging or similar even to CameraGestureObserver. And kinda deprecate |
… gestures being tracked that could lead to race conditions
…t map steady event detection is decoupled and can be minimally reused from RNMBXMapView
…ent kotlin components - refactor MapSteadyDetector so that it uses enum instead of magic strings
thanks for reviewing these changes @mfazekas ! Just wanted to get some clarification on your suggestion. Do you mean deprecate If you mean the former, do you mean that we want to keep the underlying |
To clarify: deprecate onRegionIsChanging (the MapView event), not onMapSteady. RNMBXMapView is already too complicated and the long-term plan is to split it into components — so I'd rather move code out of MapView, not into it. Concretely: CameraGestureObserver gains an onRegionIsChanging-like event (say onCameraChange) reporting isUserInteraction from its own gesture/animator tracking. Since it doesn't depend on MapIdle, it's immune to the pulsing puck issue. The MapView event stays as-is natively and gets deprecated in the JS API, so #3805 is addressed by migrating to the new event. Extracting MapSteadyDetector as a helper is fine — it should just stay owned by CameraGestureObserver, and the CameraChangeTracker changes wouldn't be needed. |
The MapSteadyDetector instance in RNMBXMapView only reset the camera change reason to NONE and is no longer needed. Remove it and its import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a new onMapCameraChange event that emits a camera snapshot (center, bounds, zoom, heading, pitch, isUserInteraction, timestamp) on every camera change. - add MapCameraChangeDetector to derive the change reason from live gesture/animation state and forward CameraChanged events - add MapCameraChangeEvent to serialize the snapshot into the JS shape - wire hasOnMapCameraChange prop and onMapCameraChange event through the observer, view manager, JS wrapper and codegen spec Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- add onMapCameraChange example under CameraGestureObserver
928330f to
9699111
Compare
|
I see, @mfazekas. I think I understand your reasoning here. I created a parallel I extended the example for One thing to note Im sure you're aware is that the iOS implementation is not done here. And because we are extending on CameraGestureObserver (instead of extending on the existing MapView event handler) we need to introduce it to iOS too. I'm keen to get your eyes on these sets of changes to see if Im on the right track here |
Description
Fixes #3805
Fixes Android bug where
onRegionIsChanging'sproperties.isUserInteractionwas stucktruewhenever<LocationPuck pulsing="default" />was mounted, even if there were no user action. Root cause: the LocationComponent's pulsing animator keeps the map perpetually non-idle (as reported here), so Mapbox'sMapIdleevent never fires.This means that
CameraChangeTrackernever cleared user gesture state asaddOnMapIdleListenernever fired if that<LocationPuck />component was mounted. Fix was to use the new customMapSteadyevent already introduced here #4074Changes
CameraChangeTrackerand replace singlereason: CameraChangeReasonfield withreasonByGesture: Map<MapGestureType, CameraChangeReason>so concurrent move/scale/rotate gestures don't cause race conditions.MapSteadyDetectorfromRNMBXCameraGestureObserverand use this custom event fromRNMBXMapViewto drive clearing theCameraChangeTrackerstate which corrects the downstream propagation toproperties.isUserInteractionMapGestureTypeis promoted to shared enumChecklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Component to reproduce the issue you're fixing
Just pasting the same repro code snippet provided by the original issue